<?php
class GroupsModel
{
	static private $_tableName = 'groups'; 
	
	static public function getTableName()
	{
		return self::$_tableName;
	}
	
	static public function getAllForAdmin()
	{
		$result = array();
		$sql = 'SELECT * FROM '.self::getTableName();
		$result = DB::fetchAll($sql);
		return $result;
	}
	
	static public function getAllDeals($params)
	{
		$result = array();
		$sql = 'SELECT * FROM '.self::getTableName() .' WHERE state = 1 AND city_id = :city_id';
		$data = array('city_id' => $params['city_id']);
		$result = DB::fetchAll($sql, $data);
		return $result;
	}
	
	static public function getCurrentDeal($params)
	{
		$result = array();
		$sql = 'SELECT * FROM '.self::getTableName() .' WHERE state = 1 AND city_id = :city_id';
		$data = array('city_id' => $params['city_id']);
		$result = DB::fetch($sql, $data);
		return $result;
	}
	
	static public function createDeals($params)
	{
		$sql = 'INSERT INTO '.self::getTableName() .' (city_id) VALUES (:city_id)';
		$data = array('city_id' => $params['city_id']);
		$result = DB::insert($sql, $data);
	}
	
	static public function updateBought($params)
	{
		$sql = 'UPDATE '.self::getTableName() .' SET city_id = :city_id';
		$data = array('city_id' => $params['city_id']);
		$result = DB::update($sql, $data);
	}
	
	
	
}